//
//  Game2TableViewCell.m
//  GOGOTravel
//
//  Created by dllo on 16/2/1.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "Game2TableViewCell.h"

@implementation Game2TableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
    }
    return self;
}

- (void)setModel:(Game *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    _image1.layer.cornerRadius = 12.5;
    _image1.layer.masksToBounds = YES;
    _image2.layer.cornerRadius = 12.5;
    _image2.layer.masksToBounds = YES;
    _image3.layer.cornerRadius = 12.5;
    _image3.layer.masksToBounds = YES;
    _image4.layer.cornerRadius = 12.5;
    _image4.layer.masksToBounds = YES;
    _image5.layer.cornerRadius = 12.5;
    _image5.layer.masksToBounds = YES;
    [self setValues];
}

- (void)setValues{
    
    _image1.image = [UIImage imageNamed:@"iconfont-jingdianxiangqingyejingdianjieshao-2.png"];
    _image2.image = [UIImage imageNamed:@"iconfont-zhusu.png"];
    _image3.image = [UIImage imageNamed:@"iconfont-zhongguoguoqi.png"];
    _image4.image = [UIImage imageNamed:@"iconfont-canyin.png"];
    _image5.image = [UIImage imageNamed:@"iconfont-gouwu.png"];
    NSDictionary *dic = _model.poi_infos_count;
    NSString *str = dic[@"sights"];
    _label1.text = [NSString stringWithFormat:@"%@ 景点", str];
    NSString *str1 = dic[@"hotel"];
    _label2.text = [NSString stringWithFormat:@"%@ 住宿", str1];
    NSString *str2 = dic[@"restaurant"];
    _label4.text = [NSString stringWithFormat:@"%@ 餐饮", str2];
    NSString *str3 = dic[@"mall"];
    _label5.text = [NSString stringWithFormat:@"%@ 购物", str3];
    NSArray *arr1 = _model.cities;
    for (NSString *str in arr1) {
        _label3.text = [_label3.text stringByAppendingFormat:@"%@ * ", str];
    }
   
}

- (void)awakeFromNib {
    // Initialization code
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"yeJianMoShi"] isEqualToString:@"isDay"]) {
        self.backgroundColor = DAYCOLOR;
    }else{
        self.backgroundColor = NIGHTCOLOR;
    }
    
    


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"yeJianMoShi" object:nil];
}
- (void)changeColor:(NSNotification *)notification{
    
    if ([[[NSUserDefaults standardUserDefaults]objectForKey:@"yeJianMoShi"]isEqualToString:@"isNight"]) {
        self.backgroundColor = NIGHTCOLOR;
    }else{
        
        self.backgroundColor = DAYCOLOR;
    }
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeColor" object:nil];
    [_backView release];
    [_topView release];
    [_bottomView release];
    [_image1 release];
    [_label1 release];
    [_image2 release];
    [_image3 release];
    [_image4 release];
    [_image5 release];
    [_label2 release];
    [_label3 release];
    [_label4 release];
    [_label5 release];
    [_label6 release];
    [_button release];
    [super dealloc];
}
//查看更多日程
- (IBAction)buttonAction:(id)sender {
    NSLog(@"查看更多日程");
}
@end
